﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="MetroCash.PProfileAccounts"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MetroCash"
    xmlns:common="using:MetroCash.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>

        <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
        <x:String x:Key="AppName">My Application</x:String>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <!-- Back button and page title -->
        <!--<Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>-->
        <TextBlock Margin="60,15,60,15"></TextBlock>
        <TextBlock x:Name="pageTitle" Grid.Column="1" Text="Browse your accounts" Style="{StaticResource PageHeaderTextStyle}"/>
        <Popup x:Name="popChangeProfileName"
               Grid.Column="1" 
               Grid.Row="1"
               IsLightDismissEnabled="True"
               >
            <Border Background="White" BorderThickness="{StaticResource ComboBoxPopupBorderThemeThickness}" BorderBrush="{StaticResource ComboBoxItemPressedBackgroundThemeBrush}">
                <StackPanel Margin="5">
                    <TextBlock x:Uid="Profile-ProfileName-Change" TextWrapping="Wrap" Style="{StaticResource SnappedPageHeaderTextStyle}" ></TextBlock>
                    <StackPanel Orientation="Horizontal">
                        <TextBox x:Name="txtNewProfileName" x:Uid="Profile-ProfileName-Change-PlaceHolder" HorizontalAlignment="Left" Width="400" FontSize="{StaticResource MediumFontSize24}" ></TextBox>
                        <Button x:Name="btnChangeProfileName" Click="btnChangeProfileName_Click_1">
                            <Button.Content>
                                <TextBlock x:Uid="Common-Change" FontSize="{StaticResource MediumFontSize24}"></TextBlock>
                            </Button.Content>
                        </Button>
                    </StackPanel>
                </StackPanel>
            </Border>
        </Popup>
        <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
        <TextBlock x:Name="pageSubTitle" x:Uid="Account-CurrentBalance" Style="{StaticResource PageSubheaderTextStyle}" ></TextBlock>    
        </StackPanel>
        
        <GridView x:Name="lstAccount"
                      Grid.Row="2" Grid.Column="1"
                      Padding="0,0,0,50"
                      ItemsSource="{Binding}"
                      IsItemClickEnabled="True"
                      ItemClick="lstAccount_ItemClick_1"
                      ScrollViewer.IsHorizontalScrollChainingEnabled="False"
                  SelectionMode="None">
            <GridView.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="20,0,20,0" Width="200" VerticalAlignment="Top">
                        <Image Width="200" Height="200" Stretch="UniformToFill" VerticalAlignment="Top"></Image>
                        <StackPanel>
                            <TextBlock Text="{Binding Name}" Style="{StaticResource PageSubheaderTextStyle}" HorizontalAlignment="Center"></TextBlock>
                            <TextBlock x:Uid="Account-Balance" HorizontalAlignment="Center" VerticalAlignment="Top"></TextBlock>
                            <TextBlock Text="{Binding Balance}" HorizontalAlignment="Center" FontSize="{StaticResource MediumFontSize24}" VerticalAlignment="Top"></TextBlock>
                            <TextBlock Text="{Binding Description}" TextWrapping="Wrap" Margin="0,20,0,0" VerticalAlignment="Top"></TextBlock>
                        </StackPanel>

                    </StackPanel>
                </DataTemplate>
            </GridView.ItemTemplate>
        </GridView>

        <!--</ScrollViewer>-->
        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- The back button and title have different styles when snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
    <Page.BottomAppBar>
        <AppBar x:Name="appbarBottom">
            <Grid>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                    <Button x:Name="btnAppBarSwitch" x:Uid="Profile-Switch" Style="{StaticResource RefreshAppBarButtonStyle}" Click="btnAppBarSwitch_Click_1" ></Button>
                    <Button x:Name="btnAppBarAdd" x:Uid="Profile-Add" Style="{StaticResource AddAppBarButtonStyle}" Click="btnAppBarAdd_Click_1" ></Button>

                </StackPanel>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <Button x:Name="btnAppBarEdit" x:Uid="Profile-ChangeName" Style="{StaticResource EditAppBarButtonStyle}" AutomationProperties.Name="Profile name" Click="btnAppBarEdit_Click_1" ></Button>
                    <Button x:Name="btnAppBarHelp" x:Uid="Appbar-Help" Style="{StaticResource HelpAppBarButtonStyle}"></Button>
                    
                </StackPanel>
            </Grid>
        </AppBar>
    </Page.BottomAppBar>
</common:LayoutAwarePage>
